//
//  GuideVC.m
//  mengbutou
//
//  Created by Jiafei Wei on 16/6/30.
//  Copyright © 2016年 Jiafei Wei. All rights reserved.
//

#import "GuideVC.h"
#import "MBTPre.h"
#import "LoginVC.h"
#import "MainVC.h"
#import "CommonUtil.h"
@interface GuideVC ()
@property(nonatomic,weak)UIScrollView* scrollView;
@property (weak, nonatomic) IBOutlet UIScrollView *sc1;
@end

@implementation GuideVC

-(void)viewDidLoad {
    [super viewDidLoad];//在吟唱之前获取他们的高度和宽度
    [self getHeight];//存入数据中
    self.navigationController.navigationBarHidden=YES;
    [self initGuide];
}

- (void)initGuide2
{
    CGFloat fH=SCREEN_H;
    CGFloat fW =SCREEN_W;
    NSLog(@"fullH  %f,fullW  %f",fH,fW);
    //UIScrollView *scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, fW, fH)];
   [_sc1 setContentSize:CGSizeMake(fW*12, 0)];
    [_sc1 setPagingEnabled:YES];  //视图整页显示
    [_sc1 setBounces:NO]; //避免弹跳效果,避免把根视图露出来
    
    
    UIImageView *imageview = [[UIImageView alloc] initWithFrame:CGRectMake(0*fW, 0, fW, fH)];
    [imageview setImage:[UIImage imageNamed:@"guide1"]];
    [_sc1 addSubview:imageview];
    
    
    UIImageView *imageview1 = [[UIImageView alloc] initWithFrame:CGRectMake(1*fW, 0, fW, fH)];
    [imageview1 setImage:[UIImage imageNamed:@"guide2"]];
    [_sc1 addSubview:imageview1];
    
    
    UIImageView *imageview2 = [[UIImageView alloc] initWithFrame:CGRectMake(2*fW, 0, fW, fH)];
    [imageview2 setImage:[UIImage imageNamed:@"guide3"]];
    imageview2.userInteractionEnabled = YES;
    [_sc1 addSubview:imageview2];
    
    UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];//在imageview3上加载一个透明的button
    if (self.isHelp) {
        [button setTitle:@"返回萌捕头" forState:UIControlStateNormal];
    }else{
        [button setTitle:@"立即开始" forState:UIControlStateNormal];
    }
    [button setFrame:CGRectMake(fW/2-110, fH-60, 220, 40)];
    [button addTarget:self action:@selector(firstpressed) forControlEvents:UIControlEventTouchUpInside];
    [imageview2 addSubview:button];
    //[self.view addSubview:self.scrollView];
}


- (void)initGuide
{
    CGRect rectStatus = [[UIApplication sharedApplication] statusBarFrame];
    CGFloat fH=SCREEN_H+rectStatus.size.height;
    CGFloat fW =SCREEN_W;
    NSLog(@"fullH  %f,fullW  %f",fH,fW);
    UIScrollView *scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, fW, fH)];
    [scrollView setContentSize:CGSizeMake(fW*12, 0)];
    [scrollView setPagingEnabled:YES];  //视图整页显示
    [scrollView setBounces:NO]; //避免弹跳效果,避免把根视图露出来
    
    self.scrollView = scrollView;
    
    UIImageView *imageview = [[UIImageView alloc] initWithFrame:CGRectMake(0*fW, 0, fW, fH)];
    [imageview setImage:[UIImage imageNamed:@"guide1"]];
    [self.scrollView addSubview:imageview];
    
    
    UIImageView *imageview1 = [[UIImageView alloc] initWithFrame:CGRectMake(1*fW, 0, fW, fH)];
    [imageview1 setImage:[UIImage imageNamed:@"guide2"]];
    [self.scrollView addSubview:imageview1];
    
    
    UIImageView *imageview2 = [[UIImageView alloc] initWithFrame:CGRectMake(2*fW, 0, fW, fH)];
    [imageview2 setImage:[UIImage imageNamed:@"guide3"]];
    imageview2.userInteractionEnabled = YES;
    [self.scrollView addSubview:imageview2];
  
    UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
    [button setBackgroundColor:[UIColor redColor]];
    //在imageview3上加载一个透明的button
    if (self.isHelp) {
        [button setTitle:@"返回萌捕头" forState:UIControlStateNormal];
    }else{
        [button setTitle:@"立即开始" forState:UIControlStateNormal];
    }
    [button setFrame:CGRectMake(fW/2-110, 200, 220, 40)];
    [button addTarget:self action:@selector(firstpressed) forControlEvents:UIControlEventTouchUpInside];
    [imageview2 addSubview:button];
    [self.view addSubview:self.scrollView];
}

-(void)firstpressed{//是从那里跳过来的
    MainVC *main = [[MainVC alloc]init];
    [self.navigationController pushViewController:main animated:YES];
}

-(void)getHeight{
    CGRect rectStatus = [[UIApplication sharedApplication] statusBarFrame];
    // 导航栏（navigationbar）
    CGRect rectNav = self.navigationController.navigationBar.frame;
    NSUserDefaults *d = [NSUserDefaults standardUserDefaults];
    [d setFloat:rectStatus.size.height forKey:@"stausHeight"];
    [d setFloat:rectStatus.size.width forKey:@"stausWidth"];
    [d setFloat:rectNav.size.height forKey:@"rectNavHeight"];
    [d setFloat:rectNav.size.width forKey:@"rectNavWidth"];
    [d synchronize];
}

@end
